package com.my.basic.flow.basic;

import java.util.concurrent.Flow;

/**
 * 发布者
 *
 * @author: marshal
 * @date: 2022-07-27 15:36
 */
public class IntPublisher implements Flow.Publisher<Integer> {
    @Override
    public void subscribe(Flow.Subscriber<? super Integer> subscriber) {
        for (int i = 1; i <= 5; i++) {
            System.out.println("Publishing = " + i);
            // publish data to subscriber
            subscriber.onNext(i);
        }
        subscriber.onComplete();
    }
}
